﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.SharpZipLib.Zip;
using Nini.Ini;

namespace WizAppHelper
{
    public partial class frmMain : Form
    {
        #region   公共变量
        /// <summary>
        /// 在读取的INI配置文件中加入一个临时字段，用于存储INI文件路径，以便界面双击该应用能直接用系统默认方式打开该文件。
        /// </summary>
        private const string INI_FILE_PATH = "INI文件路径";

        private enum FolderType
        {
            Public,
            Personal
        };
        #endregion

        #region 公共函数
        /// <summary>
        /// 使用系统默认的打开方式来打开传递来的参数
        /// </summary>
        /// <param name="path"></param>
        private void OpenIt(string path)
        {
            try
            {
                Process.Start(path);
            }
            catch
            {
                //吃掉异常。
            }
        }
        #endregion

        public frmMain()
        {
            InitializeComponent();

            BindingRightClickFeedback();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            ReadRecentPath();

            ReadComboBoxItems();

            CheckProcessIsExit();
        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            SaveComboBoxItems();
        }

        #region 按钮 - 选择目录 - 右键反馈
        /// <summary>
        /// 设置右键打开文件夹时候的鼠标右键点击反馈效果。
        /// </summary>
        private void BindingRightClickFeedback()
        {
            btnAppFolder.MouseDown += MouseDownEvent;
            btnAppFolder.MouseUp += MouseUpEvent;
            btnKnownledgeFolder.MouseDown += MouseDownEvent;
            btnKnownledgeFolder.MouseUp += MouseUpEvent;
        }
        /// <summary>
        /// 鼠标右键按下时的效果。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MouseDownEvent(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                var btn = ((Button)sender);
                btn.Font = new Font(btn.Font, FontStyle.Bold);
            }
        }
        /// <summary>
        /// 鼠标松开后的效果恢复。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MouseUpEvent(object sender, MouseEventArgs e)
        {
            var btn = ((Button)sender);
            btn.Font = new Font(btn.Font, FontStyle.Regular);
        }
        #endregion
        #region 按钮 - 选择目录 - 右键打开目录
        private void btnAppFolder_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                OpenIt(txbAppFolder.Text);
            }
        }

        private void btnKnownledgeFolder_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                OpenIt(txbKnowledgeFolder.Text);
            }
        }
        #endregion
        #region 按钮 - 选择目录 - 选择目录并检索应用
        private void btnAppFolder_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                txbAppFolder.Text = folderBrowserDialog1.SelectedPath;
            }
            //遍历目录下的所有应用
            ReadAppList(FolderType.Public);
        }

        private void btnKnownledgeFolder_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                txbKnowledgeFolder.Text = folderBrowserDialog1.SelectedPath;
            }
            //遍历目录下的所有应用
            ReadAppList(FolderType.Personal);
        }

        /// <summary>
        /// 读取两个目录的应用列表。
        /// </summary>
        private void ReadAppList(FolderType folderType)
        {
            var path = Path.Combine(txbAppFolder.Text.Trim('"'), "Plugins");
            if (folderType == FolderType.Personal)
                path = Path.Combine(txbKnowledgeFolder.Text.Trim('"'), "Plugins");

            //判断插件目录是否存在
            if (!Directory.Exists(path))
                return;

            string[] files = Directory.GetFiles(path, "plugin.ini", SearchOption.AllDirectories);
            if (files.Length == 0)
                return;

            var listApps = new List<DataSourceObject>(files.Length);
            foreach (var file in files)
            {
                try
                {
                    var ini = new IniDocument(file);

                    //文件格式不对。
                    if (!ini.Sections.Contain("Common"))
                        continue;

                    //将当前配置文件的路径存入变量中。
                    var common = ini.Sections["Common"];
                    common.Set(INI_FILE_PATH, file);


                    var caption = common.GetValue("AppName_2052");

                    //当没有设置简体中文名称
                    if (caption == null)
                        caption = common.GetValue("AppName_1028");
                    //当没有设置繁体中文名称
                    if (caption == null)
                        caption = common.GetValue("AppName");
                    //当都没设置时，显示GUID
                    if (caption == null)
                        caption = "[该应用未设置AppName相关字段]" + common.GetValue("GUID");

                    listApps.Add(new DataSourceObject(caption, ini));
                }
                catch
                {
                    //吃掉
                }
            }
            if (listApps.Count == 0)
                return;

            var listBox = lsbPublic;
            if (folderType == FolderType.Personal)
                listBox = lsbPersonal;

            if (listBox.DataSource == null)
            {
                listBox.DisplayMember = "DisplayMember";
                listBox.ValueMember = "ValueMember";
            }
            listBox.DataSource = listApps.ToArray();

            SaveRecentPath(folderType);
        }
        #endregion
        #region 按钮 - 选择目录 - Enter键执行检索

        private void txbAppFolder_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                e.Handled = true;
                ReadAppList(FolderType.Public);
            }
        }

        private void txbKnowledgeFolder_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                e.Handled = true;
                ReadAppList(FolderType.Personal);
            }
        }

        #endregion

        #region 显示详细信息 - 应用相关
        /// <summary>
        /// 显示应用的Common节点的信息。
        /// </summary>
        private void ShowCommonInfo(IniDocument ini)
        {
            //文件格式不对。
            if (ini == null || !ini.Sections.Contain("Common"))
                return;

            #region 显示Common节点信息
            var common = ini.Sections["Common"];

            txbFolderName.Text = common.GetValue("FolderName");

            txbAppName.Text = common.GetValue("AppName");

            txbAppName_2052.Text = common.GetValue("AppName_2052");

            txbAppName_1028.Text = common.GetValue("AppName_1028");

            txbAppVersion.Text = common.GetValue("AppVersion");

            txbAppGUID.Text = common.GetValue("AppGUID");

            cbbAppType.Text = common.GetValue("AppType");
            if (cbbAppType.Text != "" && !cbbAppType.Items.Contains(cbbAppType.Text))
                cbbAppType.Items.Add(cbbAppType.Text);

            txbPluginCount.Text = common.GetValue("PluginCount");
            #endregion

            #region //开始获取应用里的插件列表。
            int pluginCount = Convert.ToInt16(txbPluginCount.Text);

            var listPlugin = new List<DataSourceObject>(pluginCount);
            for (int i = 0; i < pluginCount; i++)
            {
                var sectionName = "Plugin_" + i;
                if (!ini.Sections.Contain(sectionName))
                    continue;

                var tmpSection = ini.Sections[sectionName];

                var caption = tmpSection.GetValue("Caption_2052");

                //当没有设置简体中文名称
                if (caption == null)
                    caption = tmpSection.GetValue("Caption_1028");
                //当没有设置繁体中文名称
                if (caption == null)
                    caption = tmpSection.GetValue("Caption");
                //当都没设置时，显示GUID
                if (caption == null)
                    caption = "[该插件未设置caption字段]" + tmpSection.GetValue("GUID");

                listPlugin.Add(new DataSourceObject(caption, tmpSection));
            }
            #endregion

            //设置ListBox与绑定相关的属性
            if (lsbPluginList.DataSource == null)
            {
                lsbPluginList.DisplayMember = "DisplayMember";
                lsbPluginList.ValueMember = "ValueMember";
            }

            //绑定ListBox的数据源
            lsbPluginList.DataSource = listPlugin.ToArray();
        }

        private void lsbPublic_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lsbPublic.SelectedIndex == -1)
                return;

            //取消选择
            lsbPersonal.SelectedIndex = -1;

            btnPackage.Enabled = true;
            btnEdit.Enabled = true;

            ShowCommonInfo(lsbPublic.SelectedValue as IniDocument);
        }

        private void lsbPersonal_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lsbPersonal.SelectedIndex == -1)
                return;

            //取消选择
            lsbPublic.SelectedIndex = -1;

            btnPackage.Enabled = true; 
            btnEdit.Enabled = true;

            ShowCommonInfo(lsbPersonal.SelectedValue as IniDocument);
        }
        #endregion
        #region 显示详细信息 - 应用内的插件相关
        private void lsbPluginList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lsbPluginList.SelectedIndex == -1)
                return;

            ShowPluginInfo(lsbPluginList.SelectedValue as IniSection);
        }
        /// <summary>
        /// 显示应用里面的插件相关信息
        /// </summary>
        /// <param name="iniSection"></param>
        private void ShowPluginInfo(IniSection iniSection)
        {
            txbCaption.Text = iniSection.GetValue("Caption");
            txbCaption_2052.Text = iniSection.GetValue("Caption_2052");
            txbCaption_1028.Text = iniSection.GetValue("Caption_1028");

            txbGUID.Text = iniSection.GetValue("GUID");

            cbbMenuType.Text = iniSection.GetValue("MenuType");
            if (cbbMenuType.Text != "" && !cbbMenuType.Items.Contains(cbbMenuType.Text))
                cbbMenuType.Items.Add(cbbMenuType.Text);

            cbbType.Text = iniSection.GetValue("Type");
            if (cbbType.Text != "" && !cbbType.Items.Contains(cbbType.Text))
                cbbType.Items.Add(cbbType.Text);

            txbScriptFileName.Text = iniSection.GetValue("ScriptFileName");
        }
        #endregion

        #region 右键菜单项功能 - 只在选择项了才打开右键菜单
        private void cmsPublic_Opening(object sender, CancelEventArgs e)
        {
            if (lsbPublic.SelectedIndex == -1)
                e.Cancel = true;
        }

        private void cmsPersonal_Opening(object sender, CancelEventArgs e)
        {
            if (lsbPersonal.SelectedIndex == -1)
                e.Cancel = true;
        }
        #endregion
        #region 右键菜单项功能 - 打开所在目录
        private void tsmOpenFolderItemPersonal_Click(object sender, EventArgs e)
        {
            var iniDoc = lsbPersonal.SelectedValue as IniDocument;
            if (iniDoc == null)
                return;

            var path = Path.GetDirectoryName(iniDoc.Sections["Common"].GetValue(INI_FILE_PATH));

            if (path != null)
                OpenIt(path);
        }

        private void tsmOpenFolderItemPulic_Click(object sender, EventArgs e)
        {
            var iniDoc = lsbPublic.SelectedValue as IniDocument;
            if (iniDoc == null)
                return;

            var path = Path.GetDirectoryName(iniDoc.Sections["Common"].GetValue(INI_FILE_PATH));

            if (path != null)
                OpenIt(path);
        }
        #endregion
        #region 右键菜单项功能 - 打开该文件
        private void tsmOpenFileItemPersonal_Click(object sender, EventArgs e)
        {
            var iniDoc = lsbPersonal.SelectedValue as IniDocument;
            if (iniDoc == null)
                return;

            var path = iniDoc.Sections["Common"].GetValue(INI_FILE_PATH);

            if (path != null)
                OpenIt(path);
        }

        private void tsmOpenFileItemPublic_Click(object sender, EventArgs e)
        {
            var iniDoc = lsbPublic.SelectedValue as IniDocument;
            if (iniDoc == null)
                return;

            var path = iniDoc.Sections["Common"].GetValue(INI_FILE_PATH);

            if (path != null)
                OpenIt(path);
        }
        #endregion
        #region 右键菜单项功能 - 双击打开对应的配置文件
        private void lsbPersonal_DoubleClick(object sender, EventArgs e)
        {
            tsmOpenFileItemPersonal_Click(sender, e);
        }

        private void lsbPublic_DoubleClick(object sender, EventArgs e)
        {
            tsmOpenFileItemPublic_Click(sender, e);
        }
        #endregion

        #region 设置 - 读取和保存最后选择的有效目录
        private void SaveRecentPath(FolderType folderType)
        {
            var setting = Setting.GetInstance();
            switch (folderType)
            {
                case FolderType.Public:
                    setting.RecentPublicPath = txbAppFolder.Text;
                    break;
                case FolderType.Personal:
                    setting.RecentPersonalPath = txbKnowledgeFolder.Text;
                    break;
            }
            setting.Save();
        }

        private void ReadRecentPath()
        {
            var setting = Setting.GetInstance();
            txbAppFolder.Text = setting.RecentPublicPath;
            txbKnowledgeFolder.Text = setting.RecentPersonalPath;
        }
        #endregion
        #region 设置 - 读取和保存下拉框相关可选值
        /// <summary>
        /// 保存所有下拉框的可选值。
        /// </summary>
        private void SaveComboBoxItems()
        {
            var setting = Setting.GetInstance();

            var items = new string[cbbAppType.Items.Count];
            cbbAppType.Items.CopyTo(items, 0);
            setting.AppType = items;

            items = new string[cbbMenuType.Items.Count];
            cbbMenuType.Items.CopyTo(items, 0);
            setting.MenuType = items;

            items = new string[cbbType.Items.Count];
            cbbType.Items.CopyTo(items, 0);
            setting.Type = items;

            setting.Save();
        }

        /// <summary>
        /// 读取所有下拉框的可选值。
        /// </summary>
        private void ReadComboBoxItems()
        {
            var setting = Setting.GetInstance();

            if (setting.AppType != null)
            {
                cbbAppType.Items.Clear();
                cbbAppType.Items.AddRange(setting.AppType);
            }
            if (setting.MenuType != null)
            {
                cbbMenuType.Items.Clear();
                cbbMenuType.Items.AddRange(setting.MenuType);
            }
            if (setting.Type != null)
            {
                cbbType.Items.Clear();
                cbbType.Items.AddRange(setting.Type);
            }
        }
        #endregion

        #region 按钮 - 打开脚本
        /// <summary>
        /// 使用系统默认的方式打开ScriptFileName里指定的文件。
        /// </summary>
        private void btnEditScript_Click(object sender, EventArgs e)
        {
            var app = lsbPublic.SelectedValue as IniDocument ?? lsbPersonal.SelectedValue as IniDocument;
            if (app == null)
                return;

            var dirPath = Path.GetDirectoryName(app.Sections["Common"].GetValue(INI_FILE_PATH));
            if (dirPath == null)
                return;

            var plugin = lsbPluginList.SelectedValue as IniSection;
            if (plugin == null)
                return;

            var fileName = plugin.GetValue("ScriptFileName");

            var filePath = Path.Combine(dirPath, fileName);

            OpenIt(filePath);
        }
        #endregion
        #region 按钮 - 启用编辑和撤销编辑
        /// <summary>
        /// 进入编辑状态，将所有可编辑项置为可用
        /// </summary>
        private void btnEdit_Click(object sender, EventArgs e)
        {
            //开始编辑
            if (btnEdit.Tag == null)
            {

                SetEditEnabled(true);

                StoreOriginalValue();
            }
            //取消编辑
            else
            {
                SetEditEnabled(false);

                ReStoreOriginalValue();
            }
        }

        /// <summary>
        /// 撤销当前编辑，所有项恢复编辑前的值。
        /// </summary>
        private void ReStoreOriginalValue()
        {
            #region 公共属性
            txbFolderName.Text = txbFolderName.Tag as string;
            txbFolderName.Tag = null;

            cbbAppType.Text = cbbAppType.Tag as string;
            cbbAppType.Tag = null;

            txbAppVersion.Text = txbAppVersion.Tag as string;
            txbAppVersion.Tag = null;

            txbAppGUID.Text = txbAppGUID.Tag as string;
            txbAppGUID.Tag = null;

            txbAppName_2052.Text = txbAppName_2052.Tag as string;
            txbAppName_2052.Tag = null;

            txbAppName.Text = txbAppName.Tag as string;
            txbAppName.Tag = null;

            txbAppName_1028.Text = txbAppName_1028.Tag as string;
            txbAppName_1028.Tag = null;
            #endregion

            #region 插件信息
            cbbMenuType.Text = cbbMenuType.Tag as string;
            cbbMenuType.Tag = null;

            cbbType.Text = cbbType.Tag as string;
            cbbType.Tag = null;

            txbGUID.Text = txbGUID.Tag as string;
            txbGUID.Tag = null;

            txbScriptFileName.Text = txbScriptFileName.Tag as string;
            txbScriptFileName.Tag = null;

            txbCaption_2052.Text = txbCaption_2052.Tag as string;
            txbCaption_2052.Tag = null;

            txbCaption.Text = txbCaption.Tag as string;
            txbCaption.Tag = null;

            txbCaption_1028.Text = txbCaption_1028.Tag as string;
            txbCaption_1028.Tag = null;
            #endregion
        }

        /// <summary>
        /// 存储编辑前的值
        /// </summary>
        private void StoreOriginalValue()
        {
            #region 公共属性
            txbFolderName.Tag = txbFolderName.Text;
            cbbAppType.Tag = cbbAppType.Text;

            txbAppVersion.Tag = txbAppVersion.Text;
            txbAppGUID.Tag = txbAppGUID.Text;

            txbAppName_2052.Tag = txbAppName_2052.Text;
            txbAppName.Tag = txbAppName.Text;
            txbAppName_1028.Tag = txbAppName_1028.Text;
            #endregion

            #region 插件信息
            cbbMenuType.Tag = cbbMenuType.Text;
            cbbType.Tag = cbbType.Text;

            txbGUID.Tag = txbGUID.Text;
            txbScriptFileName.Tag = txbScriptFileName.Text;

            txbCaption_2052.Tag = txbCaption_2052.Text;
            txbCaption.Tag = txbCaption.Text;
            txbCaption_1028.Tag = txbCaption_1028.Text;
            #endregion
        }

        /// <summary>
        /// 将所有可编辑项置为指定状态。
        /// </summary>
        /// <param name="isEnabled"></param>
        private void SetEditEnabled(bool isEnabled)
        {
            if (isEnabled)
            {
                btnEdit.Text = "取消(&Q)";
                btnEdit.Tag = true;
            }
            else
            {
                btnEdit.Text = "编辑(&E)";
                btnEdit.Tag = null;
            }

            #region 公共属性
            txbFolderName.Enabled = isEnabled;
            cbbAppType.Enabled = isEnabled;

            txbAppVersion.Enabled = isEnabled;
            txbAppGUID.Enabled = isEnabled;

            txbAppName_2052.Enabled = isEnabled;
            txbAppName.Enabled = isEnabled;
            txbAppName_1028.Enabled = isEnabled;

            //插件数量不能手动编辑，须由软件自动生成。
            //txbPluginCount.Enabled = isEnabled;
            #endregion

            #region 插件信息
            cbbMenuType.Enabled = isEnabled;
            cbbType.Enabled = isEnabled;

            txbGUID.Enabled = isEnabled;
            txbScriptFileName.Enabled = isEnabled;

            txbCaption_2052.Enabled = isEnabled;
            txbCaption.Enabled = isEnabled;
            txbCaption_1028.Enabled = isEnabled;
            #endregion

            #region ListBox
            lsbPublic.Enabled = !isEnabled;
            lsbPersonal.Enabled = !isEnabled;
            lsbPluginList.Enabled = !isEnabled;
            #endregion

            //是否可保存
            btnSave.Enabled = isEnabled;
        }
        #endregion
        #region 按钮 - 保存相关功能
        private void btnSave_Click(object sender, EventArgs e)
        {
            var app = lsbPublic.SelectedValue as IniDocument ?? lsbPersonal.SelectedValue as IniDocument;
            if (app == null)
                return;

            var common = app.Sections["Common"];

            #region 保存Common节点信息
            common.Set("FolderName", txbFolderName.Text);

            common.Set("AppName", txbAppName.Text);

            common.Set("AppName_2052", txbAppName_2052.Text);

            common.Set("AppName_1028", txbAppName_1028.Text);

            common.Set("AppVersion", txbAppVersion.Text);

            common.Set("AppGUID", txbAppGUID.Text);

            common.Set("AppType", cbbAppType.Text);

            common.Set("PluginCount", txbPluginCount.Text);
            #endregion

            #region 保存Plugin节点信息
            var pluginSelected = lsbPluginList.SelectedValue as IniSection;
            if (pluginSelected != null)
            {
                var plugin = app.Sections[pluginSelected.Name];

                plugin.Set("Caption", txbCaption.Text);

                plugin.Set("Caption_2052", txbCaption_2052.Text);

                plugin.Set("Caption_1028", txbCaption_1028.Text);

                plugin.Set("GUID", txbGUID.Text);

                plugin.Set("MenuType", cbbMenuType.Text);

                plugin.Set("Type", cbbType.Text);

                plugin.Set("ScriptFileName", txbScriptFileName.Text);
            }
            #endregion

            //获得当前文件路径
            var filePath = app.Sections["Common"].GetValue(INI_FILE_PATH);

            //先移除该临时添加的路径
            common.Remove(INI_FILE_PATH);

            BackupFile(filePath);

            //再保存
            app.Save(filePath);

            //再添加回来。
            common.Set(INI_FILE_PATH, filePath);

            if (!FixedWhiteSpaceBug(filePath))
                return;

            MessageBox.Show("保存成功！", @"\(^o^)/"
                , MessageBoxButtons.OK
                , MessageBoxIcon.Information);

            SetEditEnabled(false);
        }

        /// <summary>
        /// 修复配置文件中 =号左右出现空白字符，程序无法识别的问题。
        /// </summary>
        private bool FixedWhiteSpaceBug(string filePath)
        {
            try
            {
                var text = File.ReadAllText(filePath);
                File.WriteAllText(filePath, text.Replace(" = ", "="), Encoding.UTF8);
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return false;
            }
        }

        /// <summary>
        /// 将指定文件就地备份。新文件名为“原文件名yyyyMMddHHmmss.后缀名”。
        /// </summary>
        /// <param name="filePath"></param>
        private void BackupFile(string filePath)
        {
            if (!File.Exists(filePath))
                return;

            var newPath = filePath.Insert(filePath.Length - 4, DateTime.Now.ToString("yyyyMMddHHmmss"));

            try
            {
                File.Copy(filePath, newPath, true);
            }
            catch
            {
                //吃掉
            }
        }
        #endregion
        #region 按钮 - 启动（重启）Wiz程序
        private void btnRestartWiz_Click(object sender, EventArgs e)
        {
            var path = Path.Combine(txbAppFolder.Text, "Wiz.exe");
            if (!File.Exists(path))
                return;

            OpenIt(path);
        }
        /// <summary>
        /// 检测Wiz是否已经启动，来调整启动（重启）参数。
        /// </summary>
        private void CheckProcessIsExit()
        {
            var process = Process.GetProcessesByName("Wiz");
            if (process.Length > 0)
                btnRestartWiz.Text = "重启Wiz(&R)";
            else
                btnRestartWiz.Text = "启动Wiz(&R)";
        }
        #endregion
        #region 按钮 - 打包功能
        private void btnPackage_Click(object sender, EventArgs e)
        {
            var app = lsbPublic.SelectedValue as IniDocument ?? lsbPersonal.SelectedValue as IniDocument;
            if (app == null)
                return;

            var dirPath = Path.GetDirectoryName(app.Sections["Common"].GetValue(INI_FILE_PATH));
            if (dirPath == null)
                return;

            saveFileDialog1.FileName = txbAppName_2052.Text;

            if (saveFileDialog1.ShowDialog() != DialogResult.OK)
                return;

            try
            {
                //过滤备份的文件。
                new FastZip().CreateZip(saveFileDialog1.FileName, dirPath, true, "-plugin2.+ini");
                MessageBox.Show("打包完成！", @"\(^o^)/"
                    , MessageBoxButtons.OK
                    , MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "(⊙０⊙)哇~恭喜你“中奖”啦！"
                    , MessageBoxButtons.OK
                    , MessageBoxIcon.Error);
            }
        }
        #endregion

        private void btnCreate_Click(object sender, EventArgs e)
        {

        }

    }
}
